<?php
	session_start(); 
	include('../user_type/system.php');
	include('../access/login_functions.php');
	include("../access/opendb.php"); 
	$_SESSION['restricted'] = true;
	check_logged_in();	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }
	
	
	$CID = $_POST['CID'];
	$fromUID = $_SESSION['ID'];
	$toUID = $_POST['UID'];
	$complaint = $_POST['complaint'];
	$complaintAgainst = $_POST['username'];
	
	// determine the type of complaint
	if (empty($CID))	// if CID == -1, complaint is directed towards user
		$CID = -1;
		
	$result = mysql_query("INSERT INTO complaint_table (complaint, fromUID, CID, toUID) VALUES ('$complaint', $fromUID, $CID, $toUID)");
	
	if ($result)
		$_SESSION['resultMessage'] = 'Successfully completed your complaint against ' . $complaintAgainst;
	else
		$_SESSION['resultMessage'] = 'Failed to generate complaint! Sorry!';
		
	include("../access/closedb.php");
	send_to_page("../" . $_SESSION['curPage']);
?>